package com.newegg.research;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

public class Token
{
	private List<Category> categories = new LinkedList<Category>();

	private Map<Category, Integer> count_in_all_categories = new HashMap<Category, Integer>();

	private int sumCount = 0;

	private String content = "undefined";

	private boolean isBrand = false;

	private boolean isProductID = false;

	public int getCountInCategory(Category c)
	{
		if (count_in_all_categories.containsKey(c))
		{
			return count_in_all_categories.get(c);
		} else
		{
			return 0;
		}
	}

	public String toString()
	{
		return content;
	}

	public int hashCode()
	{
		return content.hashCode();
	}

	public boolean equals(Object obj)
	{
		if (obj == null)
			return false;
		else if (!(obj instanceof Token))
			return false;
		else if (((Token) obj).getContent().equals(content))
			return true;
		else
			return false;
	}

	public Token(String str)
	{
		// setContent(str);
		this(str, false, false);
	}

	public Token(String str, boolean isBrand, boolean isID)
	{
		setContent(str);
		this.isBrand = isBrand;
		this.isProductID = isID;
	}

	public void increaseCount(Category category)
	{
		if (count_in_all_categories.containsKey(category))
		{
			int i = count_in_all_categories.get(category);
			count_in_all_categories.put(category, i++);
		} else
		{
			count_in_all_categories.put(category, 1);
		}
		sumCoundIncrease();
	}

	public String getContent()
	{
		return content;
	}

	public void setContent(String str)
	{
		content = str;
	}

	public int getSumCount()
	{
		return sumCount;
	}

	public void sumCoundIncrease()
	{
		sumCount++;
	}

	public void setSumCount(int sumCount)
	{
		this.sumCount = sumCount;
	}

	public boolean isProductID()
	{
		return isProductID;
	}

	public void setProductID(boolean isProductID)
	{
		this.isProductID = isProductID;
	}

	public boolean isBrand()
	{
		return isBrand;
	}

	public void setBrand(boolean isBrand)
	{
		this.isBrand = isBrand;
	}
}
